//
//  TextureFrame.cpp
//  Prism
//
//  Created by Bas du Pre on 26-05-11.
//  Copyright 2011 UU. All rights reserved.
//

#include "graphics/TextureFrame.h"

using namespace Prism;
using namespace Prism::Graphics;

TextureFrame::TextureFrame() {
    
}

TextureFrame::TextureFrame(Texture *texture, Rect rect) {
    setTexture(texture);
    setRect(rect);
}

TextureFrame::~TextureFrame() {
    
}

void TextureFrame::setTexture(Texture *texture) {
    _texture = texture;
    _rect.origin.x = 0;
    _rect.origin.y = 0;
    _rect.size = texture->size();
    EventArgs e; onChanged(this, &e);
}

Texture *TextureFrame::texture() {
    return _texture;
}

void TextureFrame::setRect(Prism::Rect rect) {
    _rect = rect;
    EventArgs e; onChanged(this, &e);
}

Prism::Rect TextureFrame::rect() {
    return _rect;
}

String TextureFrame::toString() {
    return String::fromFormat("[TextureFrame texture=%@ rect=[x: %d, y: %d, width: %d, height: %d]]", texture(), _rect.origin.x, _rect.origin.y, _rect.size.width, _rect.size.height);
}